read()) {
if (eregi("gif", $file) || eregi("jpg", $file) || eregi("png", $file))
$texturelist .= "$file ";
} closedir($textures->handle);
//put all images into an array
$texturelist = explode(" ", $texturelist);
$no = sizeof($texturelist)-2;
//generate a random number between 0 and the number of images
$random = mt_rand(0, $no);
$texture = $texturelist[$random];
//display image
echo '';
?>